package com.yxh.lib_base.ext

import android.annotation.SuppressLint
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import com.blankj.utilcode.util.ToastUtils
import java.text.SimpleDateFormat
import java.util.*


/**
 * 转date 2010-07-28 00：56：32
 */
@SuppressLint("SimpleDateFormat")
fun String.toDate(format: String = year_month_day): Date = SimpleDateFormat(format).parse(this)

/**
 * 拷贝内容
 */
fun String.copy(context: Context) {
    val clipboardManager: ClipboardManager =
        context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
    val clipData = ClipData.newPlainText("copyContent", this)
    clipboardManager.setPrimaryClip(clipData)
    ToastUtils.showShort("复制成功")
}